home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-14 | 3.6 KB | 146 lines | [TEXT/MPS ] |
- /* _________________________________________________________________________________________________________ //
- Copyright © 1993 Apple Computer, Inc. All rights reserved.
- Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
- Date: 1/2/93
- Revision comments are at the end of this file.
- ---
- GraphicsEnvTest.cp contains the needed test functions for testing out graphics environment utility classes.
- _________________________________________________________________________________________________________ */
-
- // HEADER FILES
- // Main interface for the application framework
- #ifndef _APPLICATION_
- #include "Application.h"
- #endif
-
- // For graphics environment testing
- #ifndef _GRAPHICSENV_
- #include "GraphicsEnv.h"
- #endif
-
- // CONSTANTS
- const short H = 10; // horizontal offset of graphics drawing in window
- const short V = 20; // initial vertical offset of graphics in window
- const short DELTA = 15; // delta value of vertical offsets
-
-
- // CLASSES
- class TMyApplication : public TGUIApplication
- // Our sub-TApplication class, override DoCreateDocument for creation of a special window.
- {
- public:
- TMyApplication();
- virtual void DoCreateDocument();
- };
-
-
- class TMyWindow : public TWindow
- // Override Draw to specify what is drawn in the window.
- {
- public:
- virtual void Draw();
- };
-
-
- TMyApplication::TMyApplication()
- {
- }
-
-
- // MEMBER FUNCTIONS
- #pragma segment Application
- void TMyApplication::DoCreateDocument()
- {
- Str255 myTitle;
- Pstrcpy(myTitle, "\pGraphics Env. Tests");
-
- // Create this time my TMyWindow document, and add it to the TApplication list.
- TMyWindow * aWindow = new TMyWindow;
- aWindow->SetTitle(&myTitle);
- this->AddDocument(aWindow);
-
- // Quick test, show and hide the window.
- aWindow->Hide();
- Delay(60 * 1, NULL);
- aWindow->Show();
- }
-
-
- // Global styles
- TFontEnvironment myGenevaBold(srcOr,
- geneva,
- 9,
- bold);
- TFontEnvironment myGenevaInvBold(notSrcCopy,
- geneva,
- 10,
- bold);
-
- TPenEnvironment myThickLine(srcOr,
- qd. dkGray,
- 5,
- 5);
-
- TColorEnvironment myMetalGray(36000,
- 40500,
- 37500);
- TColorEnvironment myMetalBlue(26312,
- 14340,
- 47359);
-
-
- #pragma segment Window
- void TMyWindow::Draw()
- {
- // Paint background in metal color
- myMetalGray.SetForeground(); // set gray foreground
- Rect windowRect = this->GetExtent(); // get window extent
- ::PaintRect(&windowRect); // paint background with gray
-
- // Set real background & foreground colors
- myMetalBlue.SetForeground(); // set blue paint foreground
- myMetalGray.SetBackground(); // set gray background
-
- // Draw something into my special window.
- ::MoveTo(H, V);
- myGenevaBold.Set();
- ::DrawString("\pThis is a color and Quickdraw test.");
-
- ::MoveTo(H, V + DELTA);
- myGenevaInvBold.Set();
- ::DrawString("\pI will use various classes, do");
-
- ::MoveTo(H, V + 2 * DELTA);
- myGenevaBold.Reset(); // reset font values to default state
- ::DrawString("\pthey they work or not?");
-
- ::MoveTo(H, V + 3 * DELTA);
- myThickLine.Set(); // draw thick line
- ::Line(200, 0);
- myThickLine.Reset(); // back to thin lines
- ::MoveTo(H, V + 4 * DELTA);
- ::Line(200, 0);
- ::MoveTo(H, V + 5 * DELTA);
- ::Line(200, 0);
-
- ::PenNormal(); // restore pen
- }
-
-
- // M A I N F U N C T I O N
- void main(void)
- {
- TMyApplication * myApp = new TMyApplication;
- myApp->Start();
- }
-
-
- // _________________________________________________________________________________________________________ //
-
- /* Change History (most recent last):
- No Init. Date Comment
- 1 khs 1/2/93 New file
- 2 khs 1/7/93 Cleanup
- */
-
-